package org.example.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 用户基本信息实体类
 * 包含用户的基本信息和收货地址信息
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("mall_user_info")
public class MallUserInfo implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 下单订单号
     */
    @TableField("order_number")
    private String orderNumber;

    /**
     * 放款时间
     */
    @TableField("loan_time")
    private LocalDateTime loanTime;

    /**
     * 放款金额
     */
    @TableField("loan_amount")
    private BigDecimal loanAmount;
    /**
     * 期数
     */
    @TableField("loan_term")
    private String loanTerm;

    /**
     * 期数
     */
    @TableField("installment_count")
    private Integer installmentCount;

    /**
     * 收货地址省
     */
    @TableField("shipping_province")
    private String shippingProvince;

    /**
     * 收货地址市
     */
    @TableField("shipping_city")
    private String shippingCity;

    /**
     * 收货地址区
     */
    @TableField("shipping_district")
    private String shippingDistrict;

    /**
     * 性别(0女1男)
     */
    @TableField("gender")
    private String gender;

    /**
     * 生日
     */
    @TableField("birthday")
    private LocalDate birthday;

    /**
     * 月收入
     */
    @TableField("monthly_income")
    private BigDecimal monthlyIncome;

    /**
     * 学历
     */
    @TableField("education")
    private String education;

    /**
     * 婚姻状况
     */
    @TableField("marital_status")
    private String maritalStatus;

    /**
     * 芝麻信用分
     */
    @TableField("sesame_score")
    private Integer sesameScore;

    /**
     * 创建时间
     */
    @TableField("create_time")
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField("update_time")
    private LocalDateTime updateTime;
    /**
     * 年龄
     */
    private Integer age;
    /**
     * 手机号
     */
    private String userPhone;
    /**
     * 身份证号码
     */
    private String userIdNo;
    /**
     * 用户姓名
     */
    private String userName;

    /**
     * 性别枚举
     */
    public enum Gender {
        FEMALE(0, "女"),
        MALE(1, "男");

        private final Integer code;
        private final String desc;

        Gender(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public Integer getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }

        public static Gender fromCode(Integer code) {
            for (Gender gender : values()) {
                if (gender.getCode().equals(code)) {
                    return gender;
                }
            }
            return null;
        }
    }
}
